home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 6357 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  58 lines

  1. Path: rcp6.elan.af.mil!rscernix!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c,comp.sys.amiga.programmer
  4. Subject: Re: pointer conversion error
  5. Date: 26 Mar 96 18:18:18 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.827864298@rscernix>
  8. References: <4j39n1$mh4@news.xs4all.nl> <676.6658T1354T436@mistral.co.uk> <4j865t$npa@btmpjg.god.bel.alcatel.be>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11.  
  12. In <4j865t$npa@btmpjg.god.bel.alcatel.be> barnhoorn@nlev00 () writes:
  13.  
  14. >In article <676.6658T1354T436@mistral.co.uk>, ghira@mistral.co.uk (Adam Atkinson) writes:
  15. >>On 24-Mar-96 10:55:29, Falstaff said:
  16. >>>ghira@mistral.co.uk (Adam Atkinson) writes:
  17. >>
  18. >>>>my c compiler (SAS/C version 6.56) creates a warning about the following:
  19. >>
  20. >>>>                        printf("%u %u %u \n", i, l, h);
  21. >>
  22. >>>>three.c 36 Warning 104: conversion from pointer to const/volatile to pointer
  23. >>>>to non-const/volatile
  24. >>
  25. >>>>What am I doing wrong? i,l and h are unsigned longs.
  26. >>
  27. >>>Seems like the printf() prototype is missing.  #include <stdio.h>
  28. >>
  29. >>actually, it turns out I should have used %lu not %u. oops
  30. >>
  31. >.when this is true, then the compiler is actually checking the
  32. >string you give as first parameter of printf() !!????? Very strange.
  33.  
  34. Not strange at all.  The most popular compiler in the Unix world, gcc,
  35. does this kind of checking, if asked:
  36.  
  37.     ues5:~/tmp 11> cat test.c
  38.     #include <stdio.h>
  39.  
  40.     int main(void)
  41.     {
  42.     static unsigned long i, l, h;
  43.     printf("%u %u %u \n", i, l, h);
  44.     return 0;
  45.     }
  46.     ues5:~/tmp 12> gcc -Wall test.c
  47.     test.c: In function `main':
  48.     test.c:6: warning: unsigned int format, different type arg (arg 2)
  49.     test.c:6: warning: unsigned int format, different type arg (arg 3)
  50.     test.c:6: warning: unsigned int format, different type arg (arg 4)
  51.  
  52. Dan
  53. --
  54. Dan Pop
  55. CERN, CN Division
  56. Email: danpop@mail.cern.ch 
  57. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  58.